# Maintainer: Sébastien Luttringer
# Contributor: Kaiting Chen <kaitocracy@gmail.com>
# Contributor: mickael9 <mickael9 at gmail dot com>

pkgname=znc
pkgver=1.8.2
pkgrel=15
pkgdesc='An IRC bouncer with modules & scripts support'
url='https://wiki.znc.in/'
license=('GPL2')
arch=('loong64' 'x86_64')
depends=('libsasl' 'icu' 'boost-libs')
makedepends=('tcl' 'python' 'perl' 'cmake' 'boost')
optdepends=('tcl: modtcl module'
            'python: modpython module'
            'perl: modperl module'
            'cyrus-sasl: saslauth module')
install=$pkgname.install
source=("https://znc.in/releases/archive/$pkgname-$pkgver.tar.gz"{,.sig}
        "$pkgname.tmpfiles"
        "$pkgname.sysusers")
validpgpkeys=('D5823CACB477191CAC0075555AE420CC0209989E') #Alexey Sokolov <alexey@asokolov.org>
sha256sums=('ff238aae3f2ae0e44e683c4aee17dc8e4fdd261ca9379d83b48a7d422488de0d'
            'SKIP'
            '8cd1b5b011c706fea9dc0c70d4daa75a53bf0966d6e96a3fce3a541777aa2771'
            '8802f1b84ab3031db7cc45678f008ceca9b08b2012412a3d4ff1ea596586bb2a')

prepare() {
  mkdir -p build
}

build() {
  cd build
  cmake ../$pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DWANT_PYTHON=ON \
    -DWANT_PERL=ON \
    -DWANT_TCL=ON \
    -DWANT_SYSTEMD=ON \
    -DSYSTEMD_DIR=/usr/lib/systemd/system
  make
}

package() {
  cd build
  make DESTDIR="$pkgdir" install
  install -Dm644 "$srcdir/$pkgname.sysusers" "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
  install -Dm644 "$srcdir/$pkgname.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf"
}
